package com.shlh.saas.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.shlh.saas.entity.PaymentOrder;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 支付订单Mapper接口
 */
@Mapper
public interface PaymentOrderMapper extends BaseMapper<PaymentOrder> {
    
    /**
     * 根据订单号查询支付订单
     * @param orderNo 订单号
     * @return 支付订单
     */
    @Select("SELECT * FROM payment_orders WHERE order_no = #{orderNo} LIMIT 1")
    PaymentOrder selectByOrderNo(@Param("orderNo") String orderNo);
    
    /**
     * 根据用户ID查询最近的支付订单
     * @param userId 用户ID
     * @param limit 查询条数
     * @return 支付订单列表
     */
    @Select("SELECT * FROM payment_orders WHERE user_id = #{userId} ORDER BY create_time DESC LIMIT #{limit}")
    PaymentOrder selectRecentByUserId(@Param("userId") Long userId, @Param("limit") Integer limit);
} 